package sharping.appilog.Adapter;

import java.util.ArrayList;

import sharping.appilog.R;
import sharping.appilog.DataTree.BizLineData;
import sharping.appilog.Logic.CategoryMatche;

import android.content.Context;
import android.location.Location;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class BizSkinAdapter extends ArrayAdapter {

	Context context;
	LayoutInflater inflater;
	ArrayList<BizLineData> item;
	int layout;
	float lat = -9999, lng = -9999;
	CategoryMatche selectIcon;

	public BizSkinAdapter(Context context, int resource,
			LayoutInflater inflater, int Type, ArrayList<BizLineData> item,
			float lat, float lng) {
		super(context, resource, item);

		this.context = context;
		this.inflater = inflater;
		this.item = item;
		this.layout = resource;

		this.lat = lat;
		this.lng = lng;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return 3;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		mHolder v;

		switch (position) {
		case 0:
			convertView = inflater.inflate(R.layout.list_bizskin_silver_center, null);
			break;

		case 1:
			convertView = inflater.inflate(R.layout.list_bizskin_bronze, null);
			break;

		case 2:
			convertView = inflater.inflate(R.layout.list_bizskin_gold_center, null);
			break;

		default:
			break;
		}

		// if (convertView == null) {
		// v = new mHolder();
		// convertView = inflater.inflate(layout, null);
		//
		// v.name = (TextView)
		// convertView.findViewById(R.id.list_bizskin_BizName);
		// v.timelinecount = (TextView)
		// convertView.findViewById(R.id.list_bizskin_TimeLineCount);
		// v.location = (TextView)
		// convertView.findViewById(R.id.list_bizskin_BizLocation);
		//
		// v.category = (ImageView)
		// convertView.findViewById(R.id.list_bizskin_BizCategory);
		//
		// convertView.setTag(v);
		// } else {
		// v = (mHolder) convertView.getTag();
		// }
		//
		// v.name.setText(item.get(position).getCBizName());
		// v.timelinecount.setText(item.get(position).getCTimeLineCount());
		//
		// if (!(lat == -9999 || lng == -9999)) {
		// float bizlat = Float.valueOf(item.get(position).getCBizLat());
		// float bizlng = Float.valueOf(item.get(position).getCBizLng());
		//
		// float[] distance = new float[2];
		//
		// Location.distanceBetween(lat, lng, bizlat, bizlng, distance);
		//
		// v.location.setText(String.valueOf(distance[0]));
		// } else {
		//
		// }
		// selectIcon = new CategoryMatche(context,
		// item.get(position).getCBizCategory());
		// v.category.setImageResource(selectIcon.getIconRes());

		return convertView;
	}

	private class mHolder {
		TextView name, location, timelinecount;
		ImageView category;
	}

}
